<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>无标题文档</title>
		<script type="text/javascript" src="__STATIC__/js/jquery-1.8.2.min.js"></script>
		<script type="text/javascript" src="__STATIC__/js/hdjs.min.js"></script>
		<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
		<link href="__STATIC__/uploadify/uploadify.css" type="text/css" rel="stylesheet"></link>
		<link href="__VIEW__/css/style1.css" rel="stylesheet" type="text/css" />
		<link rel="stylesheet" href="__STATIC__/css/hdjs.css" />
		<link href="__VIEW__/css/select.css" rel="stylesheet" type="text/css" />
		<script>
//			alert('注意,当修改商品时他的库存会被删除');
			var ajaxTypeAttr = "{|U:'ajaxTypeAttr'}";
			var getGoodsAttr = "{|U:'getGoodsAttr'}";
			var gid = "{$goods.gid}";
			//当前的分类ID
			var cateid = "{$goods.goods_cateid}";
		</script>
		<script type="text/javascript" src="__VIEW__/js/jquery.idTabs.min.js"></script>
		<script type="text/javascript" src="__CONTROLLER_VIEW__/js/editgoods.js"></script>
		<script type="text/javascript" charset="utf-8" src="__STATIC__/ueditor/ueditor.config.js"></script>
		<script type="text/javascript" charset="utf-8" src="__STATIC__/ueditor/ueditor.all.min.js"></script>
		<script type="text/javascript" charset="utf-8" src="__STATIC__/ueditor/lang/zh-cn/zh-cn.js"></script>
		<style type="text/css">
			select{
				opacity: 1;
				width:345px;
				height:35px;
				margin-bottom:5px;
				border:1px solid #999;
			}
		</style>
		<script>
			var ue = UE.getEditor('editor', {
				initialFrameWidth: 1000,
				initialFrameHeight: 400
			});
		</script>

	</head>

	<body>

		<div class="place">
			<span>位置：</span>
			<ul class="placeul">
				<li><a href="#">首页</a>
				</li>
				<li><a href="#">商品管理</a>
				</li>
				<li><a href="">添加商品</a>
				</li>
			</ul>
		</div>

		<div class="formbody">

			<div id="usual1" class="usual">

				<div class="itab">
					<ul>
						<li><a href="#tab1" class="selected">商品基础信息</a>
						</li>
						<li><a href="#tab2">商品属性</a>
						</li>
						<li><a href="#tab3">商品规格</a>
						</li>
						<li><a href="#tab4">商品详细信息</a>
						</li>
						<li><a href="#tab5">商品图册</a>
						</li>
					</ul><b style="color:red">注意：修改商品是会自动删除此商品之前的库存</b>
				</div>
				<form method="post" id="goodsForm" action="{|U:'subEditGoods'}">
					<div id="tab1" class="tabson">
						<input type="hidden" name="admin_aid" value="{$hd.session.aid}" />
						<input type="hidden" name="gid" value="{$hd.get.gid}" />

						<ul class="forminfo">
							<li>
								<label>商品名<b>*</b>
								</label>
								<input name="goods_name" value="{$goods.goods_name}" type="text" class="dfinput" placeholder="请输入商品名" style="width:345px;" />
							</li>
							<li>
								<label>商城价格<b>*</b>
								</label>
								<input name="shop_price" value="{$goods.shop_price}" type="text" class="dfinput" placeholder="请输入商城价格" style="width:345px;" />
							</li>
							<li>
								<label>市场价</label>
								<input name="goods_market" value="{$goods.goods_market}" type="text" class="dfinput" placeholder="请输入市场价" style="width:345px;" />
							</li>

							<li>
								<label>分类<b>*</b>
								</label>
								<div class="vocation">
									<select class="select1" name="goods_cateid">
										<option value="0">请选择</option>
										<foreach from="$category" key="$key" value="$val">
											<option value="{$val.cid}" type_id="{$val.type_id}" <if value="$goods.goods_cateid==$val.cid">selected="selected"</if> >{$val._name}</option>
										</foreach>
									</select>
								</div>
								<input type="hidden" name="goods_typeid" id="goods_typeid" />
							</li>
							<!--<li>
								<label>商品状态</label>
								<label for="isok">正常
									<input name="goods_status" type="radio" value="1"  id="isok" <if value="$goods.goods_status==1">checked="checked"</if>>
								</label>
								<label for="isdown">下架
									<input name="goods_status" type="radio" value="0" id="isdown" <if value="$goods.goods_status==0">checked="checked"</if> >
								</label>
							</li>-->
							<li>
								<label>货号</label>
								<input name="goods_sn" value="{$goods.goods_sn}" type="text" class="dfinput" placeholder="请输入货号" style="width:345px;" /><b>*</b>如果不输入会自动生成</li>
							<li>

								<label>品牌</label>
								<div class="vocation">
									<select class="select1" name="goods_brandid">
										<option value="0">请选择</option>
										<foreach from="$brand" key="$key" value="$val">
											<option value="{$val.bid}" <if value="$val.bid==$goods.goods_brandid">selected="selected"</if> >{$val.bname}</option>
										</foreach>
									</select>
								</div>
							</li>

							<li>
								<label>列表图</label>
								<input name="goods_imglist" id="goods_imglist" type="file" /> 类型: *.jpg,*.png 大小: 2000KB
								<script type="text/javascript">
									$(function() {
										//异步处理上传图片
										$('#goods_imglist').uploadify({
											'formData': { //POST数据
												'<?php echo session_name();?>': '<?php echo session_id();?>',
											},
											'fileTypeDesc': '上传文件', //上传描述
											'fileTypeExts': '*.jpg;*.png',
											'swf': '__STATIC__/uploadify/uploadify.swf',
											'uploader': '{|U:"uploadListImg"}',
											'buttonText': '选择文件',
											'fileSizeLimit': '2000KB',
											'uploadLimit': 1000, //上传文件数
											'width': 65,
//											'debug':true,
											'height': 25,
											'successTimeout': 10, //等待服务器响应时间
											'removeTimeout': 0.2, //成功显示时间
											'onUploadSuccess': function(file, data, response) {
												data = $.parseJSON(data);
												var li = '';
												var input = '';
												$.each(data,function(k,v){
													input = '<input type="hidden" name="goods_listimg" value="'+v+'"/>';
													
													 li += '<li style="height:auto;float:left;width:230px;text-align:center;"><span>'
													 li += '<img src="__ROOT__/'+v+'" width="168" height="126" /></span>';
													 li += '<h2><a href="javascript:;" >'+v+'</a></h2>';
													 li += input;
													 li += '<p><a href="javascript:;" filename="'+v+'" class="delImg">删除</a></p></li>';
												});
												//把地址放到隐藏域，这样可以提交到服务器了
												$(".goodslist").html(li);
											}
										});
									});
								</script>
							</li>
							<ul class="goodslist">
								<if value="!empty($goods.goods_listimg)">
									
										<li style="height:auto;float:left;width:230px;text-align:center;"><span>
											<img src="__ROOT__/{$goods.goods_listimg}" width="168" height="126" /></span>
											<h2><a href="javascript:;" >{$goods.goods_listimg}</a></h2>
											<input type="hidden" name="goods_listimg" value="{$goods.goods_listimg}" />
											<p><a href="javascript:;" filename="{$goods.goods_listimg}" class="delListImg">删除</a>
											</p>
										</li>
										<script>
											//当点击删除列表图片按钮
											$('.delListImg').click(function(){
//												//获得当前的gid
												var $isThis = $(this);
												var filename = $(this).attr('filename');
												$.ajax({
													url:'__CONTROLLER__/dellistImg',
													type:'post',
													data:{gid:gid,filename:filename},
													dataType:'json',
													success:function(phpData){
														if(phpData=='1'){
															$isThis.parents('li').remove();
														}
													}
												});
											})
										</script>
									
								</if>
							</ul>
							<li>
								<label>单位</label>
								<input name="goods_unit" value="{$goods.goods_unit}" type="text" class="dfinput" placeholder="请输入商品单位" style="width:345px;" />
							</li>
							<li>
								<label>点击次数</label>
								<input name="goods_click" value="{$goods.goods_click}" type="text" class="dfinput" placeholder="默认点击次数" style="width:345px;" />
							</li>

							<li>
								<label>&nbsp;</label>
								<input name="" type="submit" class="btn" value="修改商品" />
							</li>
						</ul>

					</div>

					<div id="tab2" class="tabson">
						<!--遍历商品属性-->
						<ul class="forminfo goodsattr">
							<foreach from="$typeattrs" key="$key" value="$val">
								<li>
									<label>{$val.attrname}</label>
									<div class="vocation">
										<select class="select1" name="typeattr_id[{$val.id}]">
											<option value="0">请选择</option>
											<foreach from="$val.attrvalue" key="$k" value="$v">
												<option value="{$v}" <if value="in_array($v,$goodsAttr)">selected="selected"</if>>{$v}</option>
											</foreach>
										</select>
									</div>
								</li>
							</foreach>
						</ul>
						<ul class="forminfo">
							<li>
								<label>&nbsp;</label>
								<input name="" type="submit" class="btn" value="修改商品" />
							</li>
						</ul>

					</div>
					<div id="tab3" class="tabson">
						<ul class="forminfo goodsspec">
							<!--遍历商品规格 -->
							<foreach from="$goodsSpec" key="$key" value="$val">
								<li>
									<label>{$val.attrname}</label>
									<div class="vocation">
										<select class="select1" name="spec_id[{$val.id}][]">
											<option value="0">请选择</option>
											<foreach from="$val.attrvalue" key="$k" value="$v">
												<option value="{$v}" <if value="$v==$val.attr_value">selected="selected"</if> >{$v}</option>
											</foreach>
										</select>
									</div>
									<label style="margin-left:10px;">附加价格:</label>
									<input type="text" style="width:100px;margin-right:10px;" name="added_price[{$val.id}][]" value="{$val.added_price}" class="dfinput" /><a href="javascript:;" class="hd-btn hd-btn-primary hd-btn-sm addOne">添加规格</a>
									<a href="javascript:;" class="hd-btn hd-btn-danger hd-btn-sm delOne">删除一项</a>
								</li>
							</foreach>
						</ul>
						<ul class="forminfo">
							<li>
								<label>&nbsp;</label>
								<input name="" type="submit" class="btn" value="修改商品" />
							</li>
						</ul>
					</div>
					<div id="tab4" class="tabson">
						<textarea id="editor" name="intro" rows="10" cols="10">{$goods.intro}</textarea>
						<ul class="forminfo">
							<li>
								<label>&nbsp;</label>
								<input name="" type="submit" class="btn" value="修改商品" />
							</li>
						</ul>
					</div>
					<div id="tab5" class="tabson">
						<div lab="uploadFile">
							<input id="file" type="file" multiple="true">
							<span>类型: *.jpg,*.png 大小: 2000KB 数量: 10</span>
							<script type="text/javascript">
								$(function() {
									//异步处理上传图片
									$('#file').uploadify({
										'formData': { //POST数据
											'<?php echo session_name();?>': '<?php echo session_id();?>',
										},
										'fileTypeDesc': '上传文件', //上传描述
										'fileTypeExts': '*.jpg',
										'swf': '__STATIC__/uploadify/uploadify.swf',
										'uploader': '{|U:"upload"}',
										'buttonText': '选择文件',
										'fileSizeLimit': '2000KB',
										'uploadLimit': 1000, //上传文件数
										'width': 65,
//										'debug':true,
										'height': 25,
										'successTimeout': 10, //等待服务器响应时间
										'removeTimeout': 0.2, //成功显示时间
										'onUploadSuccess': function(file, data, response) {
											data = $.parseJSON(data);
											var li = '';
//											var str = '';
											var input = '';
											input = '<input type="hidden" name="imgs[]" value="'+data.filename+'"/>';
												li += '<li style="height:auto;"><span>'
												li += '<img src="__ROOT__/'+data.thumb+'" width="168" height="126" /></span>';
												li += '<h2><a href="javascript:;" ></a></h2>';
												li += input;
												li += '<p><a href="javascript:;" fileext="'+data.ext+'" filename="'+data.filename+'" class="delImg">删除</a></p></li>';
											//把地址放到隐藏域，这样可以提交到服务器了
										$(".imglist").prepend(li);
										}
									});
								});
							</script>
						</div>
						<ul class="imglist">
							<foreach from="$photo" key="$imgk" value="$imgv">
								<li style="height:auto;"><span>
								<input type="hidden" name="gid" value="{$hd.get.gid}" />
								<input type="hidden" name="file" value="{$imgv}" />
								<img src="__ROOT__/{$imgv}_medium.jpg" width="168" height="126" /></span>
									<h2><a href="javascript:;" ></a></h2>
									<p><a href="javascript:;" filename="{$imgv}" class="delImg">删除</a>
									</p>
								</li>
							</foreach>
						</ul>
						<input name="" type="submit" class="btn" value="修改商品" />
					</div>
			</div>

			<script type="text/javascript">
				$("#usual1 ul").idTabs();
				$('.delImg').live('click',function(){
					$isThis = $(this);
					var imgpath = $(this).attr('filename');
					var gid = {$hd.get.gid};
					//ajax删除那个文件  //再删除数据库中相应的那个图片数据
					$.ajax({
						url:'__CONTROLLER__/delImg',
						type:'post',
						data:{imgpath:imgpath,gid:gid},
						dataType:'json',
						success:function(phpData){
							if(phpData==1){
								$isThis.parents('li').remove();	
							}
						}
					})
				});
			</script>

			<script type="text/javascript">
				$('.tablelist tbody tr:odd').addClass('odd');
			
				$('#goodsForm').submit(function(){
					var isok = confirm('您确定要修改吗,修改的话会删除原有的货品库存');
			    	if(isok){
			    		return true;
			    	}
			    	return false;
   				});
		</script>


		</div>
		</form>
		<!--<form action="{|U:'upload'}" method="post" enctype="multipart/form-data">
		<input type="file" name="file"  />
		<input type="submit" />
	</form>		-->

	</body>

</html>